<?php
/**
 * Created by PhpStorm.
 * User: dev
 * Date: 7/10/14
 * Time: 1:07 PM
 */

class Site_Widget_Featured_Controller extends Base_Controller {

    public $restful = true;

    public function __construct()
    {
        parent::__construct();
        //--Your Code --//
    }


    public function get_index($location=0){
        //--Show Parent Locations--//
        $limit = Config::get('Site::featured.count') ;
        $today = date('Y/m/d', time());

        $sql = "SELECT P.* from post P
			INNER JOIN featured F on P.id = F.post_id
			AND P.status='51' and F.valid_upto >= DATE_FORMAT('{$today}','%Y-%m-%d') group by P.id order by valid_upto DESC Limit 0, $limit";

        //die($sql);
        $result = DB::query($sql);



        $data['featured'] = $result;
        return View::make('Site::widget.featured',$data);
    }
}